<html>
<head><meta charset="utf-8"><title>Embedding post-LTO bitcode via linker plugin seems broken · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Embedding.20post-LTO.20bitcode.20via.20linker.20plugin.20seems.20broken.html">Embedding post-LTO bitcode via linker plugin seems broken</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236476376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Embedding%20post-LTO%20bitcode%20via%20linker%20plugin%20seems%20broken/near/236476376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Embedding.20post-LTO.20bitcode.20via.20linker.20plugin.20seems.20broken.html#236476376">(Apr 28 2021 at 09:28)</a>:</h4>
<p>Hi wg-llvm,</p>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> and I have been trying to figure out why embedding post-LTO bitcode (via linker plugin) is not behaving as expected. I'm keen to make this work so that I can use it  in a research project.</p>
<p>Yesterday we conversed in <a href="https://github.com/rust-lang/rust/issues/84395">this issue</a> and to summarise, we'd expect something like this to work:</p>
<div class="codehilite"><pre><span></span><code>RUSTFLAGS=&quot;-C linker_plugin_lto -C linker=clang -C link-arg=-fuse-ld=lld \
    -C link-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized&quot; cargo build --release
</code></pre></div>
<p>But:</p>
<ul>
<li>The end binaries contains many concatenated bitcode modules in its <code>.llvmbc</code> section (there should be just one module in there).</li>
<li>The bitcode appears to be pre-LTO.</li>
<li>...despite putting debug prints in libLTO to confirm that it's taking the <code>EmbedOptimized</code> path, which It appears to be.</li>
</ul>
<p>At this point we are stumped. rustc is doing something which causes the incorrect result, but we are not sure what.</p>
<p>Posting here because it's likely that someone here is knowledgeable in this space. Any help would be much appreciated.</p>
<p>Thanks</p>



<a name="236476464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Embedding%20post-LTO%20bitcode%20via%20linker%20plugin%20seems%20broken/near/236476464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Embedding.20post-LTO.20bitcode.20via.20linker.20plugin.20seems.20broken.html#236476464">(Apr 28 2021 at 09:29)</a>:</h4>
<p>For reference it does work correctly when using clang instead of rustc.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>